package com.mdd.admin.controller.yylq;

import com.mdd.admin.aop.Log;
import com.mdd.admin.service.yylq.ITAppPolicySubsidiesService;
import com.mdd.admin.validate.commons.IdValidate;
import com.mdd.admin.validate.commons.PageValidate;
import com.mdd.admin.validate.yylq.TAppPolicySubsidiesCreateValidate;
import com.mdd.admin.validate.yylq.TAppPolicySubsidiesSearchValidate;
import com.mdd.admin.validate.yylq.TAppPolicySubsidiesUpdateValidate;
import com.mdd.admin.vo.yylq.TAppPolicySubsidiesDetailVo;
import com.mdd.admin.vo.yylq.TAppPolicySubsidiesListedVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/adminapi/yylq/subsidies")
@Api(tags = "羊羊领企---领企管家---企业政策补贴管理")
public class TAppPolicySubsidiesController {

    @Resource
    ITAppPolicySubsidiesService iTAppPolicySubsidiesService;

    @GetMapping("/list")
    @ApiOperation(value="领企管家---企业政策补贴列表")
    public AjaxResult<PageResult<TAppPolicySubsidiesListedVo>> list(@Validated PageValidate pageValidate,
                                                     @Validated TAppPolicySubsidiesSearchValidate searchValidate) {
        PageResult<TAppPolicySubsidiesListedVo> list = iTAppPolicySubsidiesService.list(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    @ApiOperation(value="领企管家---企业政策补贴详情")
    public AjaxResult<TAppPolicySubsidiesDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        TAppPolicySubsidiesDetailVo detail = iTAppPolicySubsidiesService.detail(id);
        return AjaxResult.success(detail);
    }

    @Log(title = "领企管家---企业政策补贴新增")
    @PostMapping("/add")
    @ApiOperation(value="领企管家---企业政策补贴新增")
    public AjaxResult<Object> add(@Validated @RequestBody TAppPolicySubsidiesCreateValidate createValidate) {
        iTAppPolicySubsidiesService.add(createValidate);
        return AjaxResult.success();
    }

    @Log(title = "领企管家---企业政策补贴编辑")
    @PostMapping("/edit")
    @ApiOperation(value="领企管家---企业政策补贴编辑")
    public AjaxResult<Object> edit(@Validated @RequestBody TAppPolicySubsidiesUpdateValidate updateValidate) {
        iTAppPolicySubsidiesService.edit(updateValidate);
        return AjaxResult.success();
    }

    @Log(title = "领企管家---企业政策补贴删除")
    @PostMapping("/del")
    @ApiOperation(value="领企管家---企业政策补贴删除")
    public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
        iTAppPolicySubsidiesService.del(idValidate.getId());
        return AjaxResult.success();
    }

}
